package com.cdu.practicaltraining.sys.handler;

import com.cdu.practicaltraining.pojo.EmpsRoles;
import com.cdu.practicaltraining.sys.mapper.EmpRoleMapper;
import com.cdu.practicaltraining.sys.service.EmpRoleService;
import com.cdu.practicaltraining.utils.CommonResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/pri")
public class EmpRoleHandler {

    @Resource
    private EmpRoleService empRoleService;
    @PostMapping("/add")
    public CommonResult addRole(@RequestBody EmpsRoles empsRoles) {
        try {
            int i = empRoleService.add(empsRoles);
            return 1 == i ? CommonResult.success(empsRoles) : CommonResult.error(201, "授权失败,请重试……");
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.error(500, "系统异常,授权失败,请联系管理员.");
        }
    }
}